package cn.modificator.relationtree.widgets

import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.util.AttributeSet
import android.view.Gravity
import android.widget.LinearLayout
import android.widget.TextView
import org.jetbrains.anko.dip

/**
 * Created by Modificator
 * time: 17/10/5.下午4:50
 * des:create file and achieve model
 */

class KindLayout(context: Context) : LinearLayout(context) {
    internal var tvTitle: TextView
    var primaryColor = 0xFF0FE3FA.toInt()
        set(value) {
            tvTitle.setTextColor(primaryColor)
            invalidate()
        }
    var title: String = ""
        set(value) {
            tvTitle.text = value
        }


    init {
        setWillNotDraw(false)
        tvTitle = TextView(context)
        tvTitle.text = "title"
        tvTitle.textSize = 12.toFloat()
        tvTitle.gravity = Gravity.CENTER_VERTICAL
        tvTitle.setPadding(0, dip(20), 0, 0)
        addView(tvTitle, LayoutParams(LayoutParams.WRAP_CONTENT, dip(44)))
        orientation = VERTICAL
        setPadding(dip(18), 0, dip(18), dip(15))
    }

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)
        val paint = Paint()
        paint.color = 0xaaaaaaaa.toInt()
        paint.strokeWidth = dip(1).toFloat()

        canvas.drawLine(0f, canvas.height - paint.strokeWidth / 2, canvas.width.toFloat(), canvas.height - paint.strokeWidth / 2, paint)
    }


}
